package com.chub.study;

import com.chub.study.entity.User;
import com.chub.study.service.UserRepository;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author : chub
 * @version : V1.0.0
 * @fileName : TUserApplicationTests.java
 * @description : TODO
 * @createTime : 2021-12-14 15:32
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class TUserJPATester {
    @Autowired
    private UserRepository userRepository;

    @Test
    public void test() throws Exception {
        // 创建1条记录
        userRepository.save(new User("AAA", 10));
        System.out.println("保存。。。。。。。。。。。");

        User u1 = userRepository.findByName("AAA");
        System.out.println("第一次查询：" + u1.getAge());

        User u2 = userRepository.findByName("AAA");
        System.out.println("第二次查询：" + u2.getAge());
    }

}
